package cn.itcast.springboot.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisUtil {


    private  static  RedisTemplate  redisTemplate;


    @Autowired
    public  void register(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }


    public static    void  set(String  key ,Object  value){
        redisTemplate.opsForValue().set(key,value);
    }

    public  static   <T> T   get(String key){
        return   (T)redisTemplate.opsForValue().get(key);
    }



}
